<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">
<head th:include="/common/head::head('编辑广告 - 广告机管理后台')"></head>
<!--/* <editor-fold desc="define"> */-->
<!--/*@thymesVar id="adminPath" type="java.lang.String"*/-->
<!--/*@thymesVar id="adminRoleID" type="java.lang.Integer"*/-->
<!--/*@thymesVar id="newEntityID" type="java.lang.Integer"*/-->
<!--/*@thymesVar id="loginUser" type="com.xmlan.machine.module.user.entity.User"*/-->
<!--/*@thymesVar id="advertisement" type="com.xmlan.machine.module.advertisement.entity.Advertisement"*/-->
<!--/*@thymesVar id="machineList" type="java.util.List<com.xmlan.machine.module.advertisementMachine.entity.SimpleAdvertisementMachine>"*/-->
<!--/*@thymesVar id="userList" type="java.util.List<com.xmlan.machine.module.user.entity.SimpleUser>"*/-->
<!--/*@thymesVar id="token" type="java.lang.String"*/-->
<!--/* </editor-fold> */-->

<body>
<th:block th:include="/common/header::header('advertisement')"/>

<main style="z-index: 0;">
  <div class="page-title z-depth-1 blue-grey darken-2">
    <div class="white-text">
      <span class="flow-text">
        <a class="btn-flat tooltipped" data-position="bottom" data-delay="50" data-tooltip="返回列表"
           onclick="history.go(-1);"><i class="material-icons white-text">arrow_back</i></a><span
          th:text="${advertisement.id==newEntityID?'新增广告':advertisement.name}"></span>
      </span>
    </div>
  </div>
  <br/>
  <div id="main-content" class="container">
    <form th:action="@{${adminPath}+'/advertisement/save/'+${advertisement.id}}" method="post">
      <input name="token" th:value="${token}" type="hidden"/>
      <input id="id" name="id" th:value="${advertisement.id}" type="hidden" class="validate" required="required"/>
      <input id="url" name="url" th:value="${advertisement.url}" type="hidden" class="validate"/>
      <input id="userID-ro" name="userID" th:value="${advertisement.userID}" type="hidden" class="validate"
             required="required" th:if="${loginUser.roleID!=adminRoleID}"/>
      <input id="addTime" name="addTime" th:value="${advertisement.addTime}" type="hidden" class="validate"/>

      <div class="row">
        <div class="input-field col s6 m6 l6">
          <i class="material-icons prefix">create</i>
          <input id="name" name="name" th:value="${advertisement.name}" type="text" class="validate" placeholder="输入名称"
                 required="required"/>
          <label for="name">广告名称</label>
        </div>
        <div class="input-field col s6 m6 l6">
          <i class="material-icons prefix">access_time</i>
          <input id="time" name="time" th:value="${advertisement.time}" type="text" class="text" placeholder="输入播放时间"
                 onblur="checkNumber();"/>
          <label for="time">播放时间</label>
        </div>

        <div class="input-field col s6 m6 l6">
          <i class="material-icons prefix">personal_video</i>
          <select id="machineID" name="machineID">
            <option th:each="item:${machineList}" th:value="${item.id}" th:text="${item.name}"
                    th:if="${item.id==advertisement.machineID}" selected="selected"></option>
            <option th:each="item:${machineList}" th:value="${item.id}" th:text="${item.name}"></option>
          </select>
          <label for="machineID">所属广告机</label>
        </div>
        <div class="input-field col s6 m6 l6" th:if="${loginUser.roleID==adminRoleID}">
          <i class="material-icons prefix">account_circle</i>
          <select id="userID" name="userID">
            <option th:each="item:${userList}" th:value="*{item.id}" th:text="*{item.username}"
                    th:if="${item.id==advertisement.userID}" selected="selected"></option>
            <option th:each="item:${userList}" th:value="*{item.id}" th:text="*{item.username}"></option>
          </select>
          <label for="userID">所属用户</label>
        </div>

        <div class="input-field col s12 m12 l12">
          <i class="material-icons prefix">insert_comment</i>
          <textarea id="remark" th:text="${advertisement.remark}" name="remark" class="materialize-textarea"></textarea>
          <label for="remark">备注</label>
        </div>
      </div>
      <div class="row">
        <div class="input-field col s6 m6 l6 right-align">
          <button type="reset" class="waves-effect waves-light btn"><i class="material-icons left">clear</i>清空</button>
        </div>
        <div class="input-field col s6 m6 l6 left-align">
          <button type="submit" class="waves-effect waves-light btn"><i class="material-icons right">send</i>提交</button>
        </div>
      </div>
    </form>
  </div>
</main>

<th:block th:include="/common/footer::footer"/>
<th:block th:include="/common/script::script"/>
<script type="text/javascript">
  $(function () {
    resize_footer(window.screen.width);
    $("#button-nav-menu").sideNav({
      closeOnClick: true,
      draggable: true
    });
    $(".dropdown-button").dropdown();
    $(".date-picker").pickadatee({
      closeOnSelect: true
    });
    $("#machineID").material_select();
    var roleID = '[[${loginUser.roleID}]]';
    if (roleID === '1') {
      $("#userID").material_select();
    }
    toast('[[${message}]]');
  });
</script>
</body>
</html>
